//
//  YXAboutViewController.m
//  MockProject
//
//  Created by FanYu on 25/8/2016.
//  Copyright © 2016 niuzhaowang. All rights reserved.
//

#import "YXAboutViewController.h"
#import "Config.h"
#import "YXNavigationController.h"

@interface YXAboutViewController ()

@property (nonatomic, strong) UIImageView *logoImageView;
@property (nonatomic, strong) UIImageView *slogonImageView;
@property (nonatomic, strong) UILabel *versionLabel;

@end

@implementation YXAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"关于我们";
    
    [self setupUI];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    YXNavigationController *navi = (YXNavigationController *)self.navigationController;
    [navi changeToWhiteBar];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    YXNavigationController *navi = (YXNavigationController *)self.navigationController;
    [navi changeToDefaultBar];
}


#pragma mark - Setup UI
- (void)setupUI {
    // self
    self.view.backgroundColor = [UIColor colorWithHexString:@"ffffff"];
    
    // logoImageView
    self.logoImageView = [[UIImageView alloc] init];
    self.logoImageView.image = [UIImage imageNamed:@"关于我们大icon"];
    [self.view addSubview:self.logoImageView];
    [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(235 * kScaleFactor);
        make.centerX.equalTo(self.view.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(125 * kScaleFactor, 125 * kScaleFactor));
    }];
    
    // slogon Image view
    self.slogonImageView = [[UIImageView alloc] init];
    self.slogonImageView.image = [UIImage imageNamed:@"MOCK-PROJECT"];
    [self.view addSubview:self.slogonImageView];
    [self.slogonImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.logoImageView.mas_bottom).offset(27 * kScaleFactor);
        make.centerX.equalTo(self.view.mas_centerX);
    }];
    
    // version label
    NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    self.versionLabel = [[UILabel alloc] init];
    self.versionLabel.text = [NSString stringWithFormat:@"当前版本%@", currentVersion];
    self.versionLabel.textColor = [UIColor colorWithHexString:@"ff4600"];
    self.versionLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.versionLabel];
    [self.versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.slogonImageView.mas_bottom).offset(11 * kScaleFactor);
        make.centerX.equalTo(self.view.mas_centerX);
        // iPhone4s
        if ([SDVersion deviceSize] == Screen3Dot5inch) {
            make.bottom.equalTo(self.view.mas_bottom).offset(-220 * kScaleFactor);
        } else {
            make.bottom.equalTo(self.view.mas_bottom).offset(-235 * kScaleFactor);
        }
    }];
}

@end
